package bootstrap

import (
	"gddgame.cc/galaxy/utils"
	"gddgame.cc/galaxy/utils/def"

	"gddgame.cc/galaxy/utils/orm"

	"github.com/gomodule/redigo/redis"
)

func (b *Boot) Redis() *redis.Pool {
	return b.redis
}

func (b *Boot) Store(region string) def.Store {
	if v, ok := b.expire[region]; ok {
		return b.cache.StoreExpire(region, utils.ToInt(v))
	} else {
		return b.cache.Store(region)
	}
}
func (b *Boot) Cache(region string) def.ExpireStore {
	if v, ok := b.expire[region]; ok {
		return b.cache.StoreExpire(region, utils.ToInt(v))
	} else {
		return b.cache.Store(region)
	}
}

func (b *Boot) Executor(instance string) orm.Executor {
	return b.executor
}
func (b *Boot) Close() error {
	if b.redis != nil {
		_ = b.redis.Close()
	}
	if b.db != nil {
		_ = b.db.Close()
	}
	return nil
}
